Assignment Operators

In C, the assignment operator can be used within any valid C expression. The most commonly used assignment operator is =. The general from of the assignment as required.
For example

x = 25;
y = z + 7;

The two terms; lvalue and rvalue are frequently encountered in error messages while compiling a C program. An lvalue is any object that can occur on the left side of an assignment statement. For all practical purposes, lvalue means variable and the term rvalue refers to expression on the right of the assignment, and simply means the value of an expression.

Expression such as

i = i + 5

In which the variable on the left hand side repeated immediately on the right, can be written in the composed form:

i +=5;

The operator += is called an assignment operator.

Most binary operator have corresponding assignment operator op=, where op is one of +, -, *, /, <<, >>, &, , |


If expr1 and expr2 are expression, then

Expr1 op= expr2;

Is equivalent to

Expr1= (expr1) op(expr2);

Expect that expr1 is computed only once. Notice the parentheses around expr2:

X *= y+1;

Means

X=x*y+1;



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext